package com.thinkfit.jy.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.common.lib.bean.VideoBean;
import com.common.lib.manager.DataManager;
import com.common.lib.utils.BaseUtils;
import com.thinkfit.jy.R;

import org.jetbrains.annotations.NotNull;

/**
 * 用户视频播放记录
 */
public class VideoRecordAdapter extends BaseQuickAdapter<VideoBean, BaseViewHolder> {

    private Context mContext;
    private int mMainStyle;

    public VideoRecordAdapter(Context context) {
        super(R.layout.item_video_record);
        mContext = context;
        mMainStyle = DataManager.Companion.getInstance().getMainStyle();
    }


    @Override
    protected void convert(@NotNull BaseViewHolder helper, VideoBean bean) {
        BaseUtils.StaticParams.loadImage(mContext, 0, bean.getCover(), helper.getView(R.id.iv));
        helper.setText(R.id.tvTitle, bean.getTitle())
                .setText(R.id.tvDate, bean.getDatetime())
                .setText(R.id.tvDesc, bean.getLongtime()+mContext.getString(R.string.app_minutes))
                .setText(R.id.tvKcal, bean.getKcal()+mContext.getString(R.string.app_kcal))
                .setBackgroundResource(R.id.line, mMainStyle == 3 ? com.common.lib.R.color.line4 : com.common.lib.R.color.line)
                .setGone(R.id.line, getItemPosition(bean) == getItemCount() - 1);
    }

}
